<template>
  <div>
    <Form :validOnChange="true" :model="model">
      <FormItem label="认证方式">
        <Select v-model="model.permType" :datas="perms"></Select>
      </FormItem>
      <FormItem label="加密方式">
        <Select v-model="model.signType" :datas="signData"></Select>
      </FormItem>
      <FormItem label="加密密钥">
        <Select v-model="model.key" :datas="keyData"></Select>
      </FormItem>
      <FormItem label="密钥名称">
        <input type="text" v-model="model.argName" />
      </FormItem>
    </Form>
    <div slot="footer">
      <Button :block="true" text-color="primary" @click="save">确认</Button>
    </div>
  </div>
</template>
<script>
export default {
  mounted() {
    this.$axios.post("/signkeys/select").then((res) => {
      this.keyData = res.data.data;
    });
  },
  data() {
    return {
      model: {},
      param: {
        keyName: "keyId",
        titleName: "title",
      },
      perms: [
        {
          keyId: "jwt",
          title: "JWT",
        },
        {
          keyId: "wx",
          title: "微信认证",
        },
        {
          keyId: "wxv3",
          title: "微信V3认证",
        },
      ],
      signData: [
        { keyId: "md5", title: "MD5" },
        { keyId: "rsa256", title: "RSA256" },
      ],
      keyData: [],
    };
  },
  methods: {
    initInfo(data) {
      if (!!data) {
        this.model = data;
      }
    },
    save() {
      this.$emit("setContent", this.model);
    },
  },
  deactivated() {
    this.$destroy(true);
  },
};
</script>
